import {
  Body,
  Controller,
  Delete,
  Get,
  Post,
  Put,
  Query,
} from '@nestjs/common';
import { AnimalService } from './animal.service';
import { Animals, Animal } from './interface';

@Controller('animal')
export class AnimalController {
  constructor(private readonly animalService: AnimalService) {}

  @Get('searchAll')
  searchAll(): Promise<CustomResponse<Animals>> {
    return this.animalService.searchAll();
  }

  @Get('searchOne')
  searchOne(@Query('id') id: string): Promise<CustomResponse<Animal>> {
    return this.animalService.searchOne(id);
  }

  @Post('create')
  async create(@Body() animal: Animal): Promise<CustomResponse<string>> {
    return this.animalService.createAnimal(animal);
  }

  @Put('update')
  update(@Body() data: Animal): Promise<CustomResponse<string>> {
    return this.animalService.update(data);
  }

  @Delete('dtl')
  del(@Query('id') id: string): Promise<CustomResponse<string>> {
    return this.animalService.dtl(id);
  }
}
